package com.example.greenshuttle;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class AppStart extends Activity {

	ImageView welcomeView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.activity_app_start);
		final View view = View.inflate(this, R.layout.activity_app_start, null);
		setContentView(view);

		// 渐变展示启动屏
		AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
		aa.setDuration(2000);
		view.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation arg0) {
				redirectTo();
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
			}

			@Override
			public void onAnimationStart(Animation animation) {
			}

		});

		// // 更换随机背景
		// // randomBackground();
		//
		// new Handler().postDelayed(new Runnable() {
		// @Override
		// public void run() {
		// // Intent intent = new Intent (AppStart.this,Welcome.class);
		// Intent intent = new Intent(AppStart.this, MainOrder.class);
		// startActivity(intent);
		// AppStart.this.finish();
		// }
		// }, 1000);

	}

	private void redirectTo() {
		Intent intent = new Intent(this, MainOrder.class);
		startActivity(intent);
		this.finish();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.app_start, menu);
		return true;
	}

	// public void randomBackground() {
	// switch (tuijishu(7)) {
	// case 0:
	// break;
	// case 1:
	// findViewById(R.id.welcome_background).setBackgroundDrawable(
	// getResources().getDrawable(R.drawable.welcome1));
	// break;
	// case 2:
	// findViewById(R.id.welcome_background).setBackgroundDrawable(
	// getResources().getDrawable(R.drawable.welcome2));
	// break;
	// case 3:
	// findViewById(R.id.welcome_background).setBackgroundDrawable(
	// getResources().getDrawable(R.drawable.welcome3));
	// break;
	// case 4:
	// findViewById(R.id.welcome_background).setBackgroundDrawable(
	// getResources().getDrawable(R.drawable.welcome4));
	// break;
	// case 5:
	// findViewById(R.id.welcome_background).setBackgroundDrawable(
	// getResources().getDrawable(R.drawable.welcome5));
	// break;
	// case 6:
	// findViewById(R.id.welcome_background).setBackgroundDrawable(
	// getResources().getDrawable(R.drawable.welcome6));
	// break;
	// }
	//
	// }
	//
	// private int tuijishu(int sum) {
	// Calendar c = Calendar.getInstance();
	// int sec = c.get(Calendar.SECOND);
	//
	// return (int) ((100 * Math.random() * sec) % sum);
	// }

}
